import java.util.Scanner;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2021-10-07
 * Time: 21:26
 */
public class AddOperation implements Ioperation {

    @Override
    public void work(BookList bookList) {
        if (bookList.getSize() == 10) {
            System.out.println("书库已满，无法增加书籍");
            return;
        }
        Scanner reader = new Scanner(System.in);
        String name;
        String author;
        int price;
        String type;
        System.out.print("请输入你要新增的书名：");
        name = reader.nextLine();
        System.out.print("请输入该书的作者：");
        author = reader.nextLine();
        System.out.print("请输入该书的价格：");
        price = reader.nextInt();
        reader.nextLine();
        System.out.print("请输入该书的类型：");
        type = reader.nextLine();

        int pos = bookList.getSize();
        Book book = new Book(name, author, price, type);
        bookList.setBooks(pos, book);
        bookList.setSize(bookList.getSize() + 1);
        System.out.println("书籍添加成功！");
    }
}



